<template>
  <div class="container">
    <h3>$parent 获取父组件方法</h3>
    <div class="description">
      在子组件中通过 Vue 实例的 $parent 方法获取父组件的方法
    </div>
    <br />
    <!-- <Child :boolen1="theBoolen"></Child> -->
    <Child :boolen1="theBoolen" @child-method="fatherMethodHandle"></Child>
  </div>
</template>

<script>
import Child from "./components/Child.vue";

export default {
  name: "Father",
  data() {
    return {
      theBoolen: false
    }
  },
  components: {
    Child,
  },
  methods: {
    fatherMethodHandle(index) {
      this.theBoolen = !this.theBoolen;
      console.log("我是父组件的方法");
      if (index === 1) {
        console.log("通过 $emit 触发父组件的方法");
      }
    },
  },
};
</script>

<style scoped></style>